<?php
// +----------------------------------------------------------------------
// | 品达网络 [ 品质保证，助企腾达 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.pdwl.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 萧涩啊 <wangmode@163.com>
// +----------------------------------------------------------------------
// | 支出用途管理

namespace app\models;
use think\Exception;


class Department extends BaseModel
{
    protected $table = 'sh_department';
    /**
     * 部门列表
     * @param $page
     * @param $limit
     * @return array|bool|\PDOStatement|string|\think\Collection|\think\model\Collection
     */
    public function getDataList($page,$limit)
    {
        try {
            return $this
                ->limit(($page-1)*$limit,$limit)
                ->order('id desc')
                ->select();
        }catch (\Exception $exception){
            return self::setErrorInfo($exception->getMessage());
        }
    }

    /**
     * @return float|int|string
     */
    public function getCount()
    {
        return $this->count('id');
    }

    /**
     * 部门列表
     * @return array
     */
    public function getList()
    {
        $where[] = ['status','=',1];
        return $this->where($where)->column('id,name');
    }

}
